package com.mornd.gulimall.apis.coupon;

import com.mornd.gulimall.apis.coupon.fallback.ICouponClientFallback;
import com.mornd.gulimall.apis.coupon.to.BoundsTo;
import com.mornd.gulimall.apis.coupon.to.SeckillSessionTo;
import com.mornd.gulimall.apis.coupon.to.SkuReductionTo;
import com.mornd.gulimall.common.core.result.AjaxResult;
import com.mornd.gulimall.common.core.result.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import java.util.List;


/**
 * @author: mornd
 * @dateTime: 2023/7/23 - 10:19
 */

@Validated
@FeignClient(value = "service-coupon", fallback = ICouponClientFallback.class)
public interface ICouponClient {

    /**
     * 只有通过继承 ICouponClient，@Validated 注解才会生效
     * @param boundsTo
     * @return
     */
    @PutMapping("/coupon/feign/spuBounds")
    AjaxResult saveBounds(@RequestBody @Validated BoundsTo boundsTo);

    @PutMapping("/coupon/feign/seckillSkuRelation/saveInfo")
    AjaxResult saveSkuReductions(@RequestBody List<@Valid SkuReductionTo> skuReductionTo);

    @GetMapping("/coupon/feign/latestDaysSeckillSessions")
    R<List<SeckillSessionTo>> latestDaysSeckillSessions(@RequestParam @Min(1) int day);
}
